package com.scau.meetingbook.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class OrderNoUtils {

    public static String getOrderNo(int id){
        //时间（精确到毫秒）
        DateTimeFormatter ofPattern = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
        String localDate = LocalDateTime.now().format(ofPattern);

        //5位随机数
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 5; i++) {
            sb.append((int) (Math.random() * 10)); // 生成 0 到 9 的随机数字
        }
        String randomNum = sb.toString();

        //加上id得到唯一单号
        String uid = String.valueOf(id);

        return localDate+randomNum+uid;
    }
}
